/*--------------------------------------------------------------------------------*/
#ifndef __GRAPHIC_FONT__
#define __GRAPHIC_FONT__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "graphic_texture_set.h"
#include "debug.h"
/*--------------------------------------------------------------------------------*/
class GRAPHIC_FONT : public OBJECT
{

	// -- PUBLIC

public:

    DECLARE_REF( GRAPHIC_FONT );

    // .. CONSTRUCTORS

    GRAPHIC_FONT() : OBJECT(), TextureSetSource(), FontName()
    {

    }

    virtual ~GRAPHIC_FONT()
    {

    }

    // .. METHODS

    VOID BindTexture()
    {
    	TextureSetSource->BindTexture();
    }

    VOID SetTextureSetSource( const GRAPHIC_TEXTURE_SET::REF & source )
    {
    	TextureSetSource = source;
    }

    VOID SetFontName( const TEXT & font_name )
    {
    	FontName = font_name;
    }

    const GRAPHIC_TEXTURE_SET::UV_COORD & GetUVCoord( const CHAR character ) const
    {
    	return TextureSetSource->GetUVCoord( (INT) character );
    }

    VOID LoadFromFile( const TEXT & file_name, const TEXT & font_name = "unnamed_font" )
    {
    	TextureSetSource = GRAPHIC_TEXTURE_SET::CreateTextureSetFromFile( file_name, 16, 16 );
    	SetFontName( font_name );
    }

    // .. FUNCTIONS

    static GRAPHIC_FONT::REF CreateFromFile( const TEXT & file_name, const TEXT & font_name = "unnamed_font" )
    {
    	GRAPHIC_FONT::REF
			result;
    	GRAPHIC_TEXTURE_SET::REF
			source;

    	source = GRAPHIC_TEXTURE_SET::CreateTextureSetFromFile( file_name, 16, 16 );

    	result.New();
    	result->SetFontName( font_name );
    	result->SetTextureSetSource( source );

    	return result;
    }

    // -- PRIVATE

private :

    // .. ATTRIBUTES

    GRAPHIC_TEXTURE_SET::REF
		TextureSetSource;
    TEXT
		FontName;
};
/*--------------------------------------------------------------------------------*/
#endif
